/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved.
 *
 * @file    mapi_function_inner.h
 * @brief   comm module
 * @author  HiMobileCam NDK develop team
 * @date  2019-3-26
 */
#ifndef __MAPI_FUNCTION_INNER_H__
#define __MAPI_FUNCTION_INNER_H__

#include <errno.h>
#include <time.h>
#include "hi_mapi_comm_define.h"
#include "hi_type.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

static __inline HI_S32 MAPI_Usleep(HI_U32 u32Usec)
{
    HI_S32 ret;
    struct timespec requst;
    struct timespec remain;
    remain.tv_sec = u32Usec / (MAPI_SEC2MSEC_SCALE * MAPI_MSEC2USEC_SCALE);
    remain.tv_nsec = (u32Usec % (MAPI_SEC2MSEC_SCALE * MAPI_MSEC2USEC_SCALE)) * MAPI_USEC2NSEC_SCALE;
    do {
        requst = remain;
        ret = nanosleep(&requst, &remain);
    } while (-1 == ret && errno == EINTR);
    return ret;
}


#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

#endif
